package LeetCodeP;

/**
 * TOOD
 *
 * @author long
 * @date 2019-12-08 22:09
 */
public class Soluction5279 {
    public static int subtractProductAndSum(int n) {
        int result=0;
        int j;
        int chengji=1;
        int sum=0;
        while (n!=0){
            j=n%10;
            sum=sum+j;
            chengji=chengji*j;
            result=chengji-sum;
            n=n/10;
        }

        return result;
    }

    public static void main(String[] args) {
        int i = subtractProductAndSum(4421);
        System.out.println(i);
    }
}
